package com.feedback.b;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import com.feedback.a.d;
import com.mobclick.android.t;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class c
{
  /**
   * @deprecated
   */
  // ERROR //
  public static String a(Context paramContext, JSONArray paramJSONArray)
  {
    // Byte code:
    //   0: ldc 2
    //   2: monitorenter
    //   3: aload_1
    //   4: ifnull +10 -> 14
    //   7: aload_1
    //   8: invokevirtual 18	org/json/JSONArray:length	()I
    //   11: ifne +11 -> 22
    //   14: ldc 20
    //   16: astore_2
    //   17: ldc 2
    //   19: monitorexit
    //   20: aload_2
    //   21: areturn
    //   22: ldc 20
    //   24: astore 4
    //   26: iconst_0
    //   27: istore 5
    //   29: aload_1
    //   30: invokevirtual 18	org/json/JSONArray:length	()I
    //   33: istore 6
    //   35: iload 5
    //   37: iload 6
    //   39: if_icmplt +9 -> 48
    //   42: aload 4
    //   44: astore_2
    //   45: goto -28 -> 17
    //   48: aload_1
    //   49: iload 5
    //   51: invokevirtual 24	org/json/JSONArray:getJSONArray	(I)Lorg/json/JSONArray;
    //   54: astore 10
    //   56: aload 4
    //   58: astore 11
    //   60: iconst_0
    //   61: istore 12
    //   63: iload 12
    //   65: aload 10
    //   67: invokevirtual 18	org/json/JSONArray:length	()I
    //   70: if_icmplt +10 -> 80
    //   73: aload 11
    //   75: astore 4
    //   77: goto +111 -> 188
    //   80: aload 10
    //   82: iload 12
    //   84: invokevirtual 28	org/json/JSONArray:getString	(I)Ljava/lang/String;
    //   87: ldc 30
    //   89: invokevirtual 36	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   92: ifeq +6 -> 98
    //   95: goto +99 -> 194
    //   98: aload 10
    //   100: iload 12
    //   102: invokevirtual 40	org/json/JSONArray:getJSONObject	(I)Lorg/json/JSONObject;
    //   105: astore 13
    //   107: ldc 42
    //   109: aload 13
    //   111: ldc 44
    //   113: invokevirtual 50	org/json/JSONObject:optString	(Ljava/lang/String;)Ljava/lang/String;
    //   116: invokevirtual 54	java/lang/String:equalsIgnoreCase	(Ljava/lang/String;)Z
    //   119: ifeq +75 -> 194
    //   122: aload_0
    //   123: aload 13
    //   125: invokestatic 58	com/feedback/b/c:b	(Landroid/content/Context;Lorg/json/JSONObject;)Z
    //   128: ifeq +66 -> 194
    //   131: aload_0
    //   132: aload 13
    //   134: ldc 60
    //   136: invokevirtual 50	org/json/JSONObject:optString	(Ljava/lang/String;)Ljava/lang/String;
    //   139: invokestatic 64	com/feedback/b/c:d	(Landroid/content/Context;Ljava/lang/String;)Ljava/lang/String;
    //   142: astore 14
    //   144: aload 14
    //   146: astore 11
    //   148: goto +46 -> 194
    //   151: astore 9
    //   153: aload 11
    //   155: astore 8
    //   157: aload 9
    //   159: invokevirtual 67	java/lang/Exception:printStackTrace	()V
    //   162: aload 8
    //   164: astore 4
    //   166: goto +22 -> 188
    //   169: astore_3
    //   170: ldc 2
    //   172: monitorexit
    //   173: aload_3
    //   174: athrow
    //   175: astore 7
    //   177: aload 4
    //   179: astore 8
    //   181: aload 7
    //   183: astore 9
    //   185: goto -28 -> 157
    //   188: iinc 5 1
    //   191: goto -162 -> 29
    //   194: iinc 12 1
    //   197: goto -134 -> 63
    //
    // Exception table:
    //   from	to	target	type
    //   63	144	151	java/lang/Exception
    //   7	17	169	finally
    //   22	35	169	finally
    //   48	56	169	finally
    //   63	144	169	finally
    //   157	162	169	finally
    //   48	56	175	java/lang/Exception
  }

  /**
   * @deprecated
   */
  public static List a(Context paramContext)
  {
    ArrayList localArrayList;
    monitorenter;
    try
    {
      localArrayList = new ArrayList();
    }
    finally
    {
      try
      {
        Iterator localIterator = paramContext.getSharedPreferences("feedback", 0).getAll().values().iterator();
        boolean bool = localIterator.hasNext();
        if (!(bool))
        {
          monitorexit;
          return localArrayList;
        }
        localArrayList.add(new com.feedback.a.d(new JSONArray((String)localIterator.next())));
      }
      catch (Exception localException)
      {
        while (true)
          localException.printStackTrace();
        localObject = finally;
        monitorexit;
        throw localObject;
      }
    }
  }

  /**
   * @deprecated
   */
  public static void a(Context paramContext, com.feedback.a.d paramd, int paramInt)
  {
    SharedPreferences.Editor localEditor;
    String str1;
    String str2;
    monitorenter;
    try
    {
      SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("feedback", 0);
      localEditor = localSharedPreferences.edit();
      str2 = localSharedPreferences.getString(str1, null);
    }
    finally
    {
      JSONArray localJSONArray1;
      JSONArray localJSONArray2;
      int i;
      try
      {
        localJSONArray1 = new JSONArray();
        localJSONArray2 = new JSONArray(str2);
        if (localJSONArray2.length() == 1)
        {
          localEditor.remove(paramd.c);
          localEditor.commit();
          paramd.b(paramInt);
          monitorexit;
          return;
        }
        i = 0;
        if (i > localJSONArray2.length() - 1)
          localEditor.putString(str1, localJSONArray1.toString());
      }
      catch (JSONException localJSONException)
      {
        while (true)
        {
          while (true)
            localJSONException.printStackTrace();
          localObject = finally;
          monitorexit;
          throw localObject;
          if (i != paramInt)
            localJSONArray1.put(localJSONArray2.getJSONObject(i));
          ++i;
        }
      }
    }
  }

  /**
   * @deprecated
   */
  public static void a(Context paramContext, String paramString)
  {
    int j;
    monitorenter;
    try
    {
      String[] arrayOfString;
      Object localObject2;
      SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("UmengFb_Nums", 0);
      if (!(d.a(paramString)))
      {
        arrayOfString = localSharedPreferences.getString("newReplyIds", "").split(",");
        int i = arrayOfString.length;
        localObject2 = "";
        j = 0;
        if (j < i)
          break label66;
        a(localSharedPreferences, "newReplyIds", (String)localObject2);
      }
      monitorexit;
      return;
      label66: String str1 = arrayOfString[j];
      if ((!(d.a(str1))) && (!(str1.equals(paramString))))
      {
        String str2 = localObject2 + "," + str1.trim();
        localObject2 = str2;
      }
    }
    finally
    {
      monitorexit;
    }
  }

  /**
   * @deprecated
   */
  public static void a(Context paramContext, String paramString1, String paramString2)
  {
    monitorenter;
    try
    {
      paramContext.getSharedPreferences(paramString1, 0).edit().remove(paramString2).commit();
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  /**
   * @deprecated
   */
  private static void a(SharedPreferences paramSharedPreferences, String paramString1, String paramString2)
  {
    monitorenter;
    try
    {
      paramSharedPreferences.edit().putString(paramString1, paramString2).commit();
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  public static boolean a(Context paramContext, com.feedback.a.d paramd)
  {
    return paramContext.getSharedPreferences("UmengFb_Nums", 0).getString("newReplyIds", "").contains(paramd.c);
  }

  /**
   * @deprecated
   */
  // ERROR //
  public static boolean a(Context paramContext, JSONObject paramJSONObject)
  {
    // Byte code:
    //   0: ldc 2
    //   2: monitorenter
    //   3: aload_1
    //   4: ldc 60
    //   6: invokevirtual 50	org/json/JSONObject:optString	(Ljava/lang/String;)Ljava/lang/String;
    //   9: astore_3
    //   10: aload_0
    //   11: ldc 73
    //   13: iconst_0
    //   14: invokevirtual 79	android/content/Context:getSharedPreferences	(Ljava/lang/String;I)Landroid/content/SharedPreferences;
    //   17: astore 4
    //   19: aload_3
    //   20: invokestatic 167	com/feedback/b/d:a	(Ljava/lang/String;)Z
    //   23: ifne +42 -> 65
    //   26: aload 4
    //   28: aload_3
    //   29: new 180	java/lang/StringBuilder
    //   32: dup
    //   33: ldc 201
    //   35: invokespecial 185	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   38: aload_1
    //   39: invokevirtual 202	org/json/JSONObject:toString	()Ljava/lang/String;
    //   42: invokevirtual 189	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   45: ldc 204
    //   47: invokevirtual 189	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   50: invokevirtual 193	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   53: invokestatic 178	com/feedback/b/c:a	(Landroid/content/SharedPreferences;Ljava/lang/String;Ljava/lang/String;)V
    //   56: iconst_1
    //   57: istore 5
    //   59: ldc 2
    //   61: monitorexit
    //   62: iload 5
    //   64: ireturn
    //   65: iconst_0
    //   66: istore 5
    //   68: goto -9 -> 59
    //   71: astore_2
    //   72: ldc 2
    //   74: monitorexit
    //   75: aload_2
    //   76: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   3	56	71	finally
  }

  /**
   * @deprecated
   */
  public static com.feedback.a.d b(Context paramContext, String paramString)
  {
    String str;
    monitorenter;
    try
    {
      str = paramContext.getSharedPreferences("feedback", 0).getString(paramString, null);
    }
    finally
    {
      com.feedback.a.d locald2;
      try
      {
        com.feedback.a.d locald1 = new com.feedback.a.d(new JSONArray(str));
        locald2 = locald1;
        monitorexit;
        return locald2;
      }
      catch (Exception localException)
      {
        while (true)
        {
          localException.printStackTrace();
          locald2 = null;
        }
        localObject = finally;
        monitorexit;
        throw localObject;
      }
    }
  }

  /**
   * @deprecated
   */
  public static boolean b(Context paramContext, JSONObject paramJSONObject)
  {
    String str1;
    SharedPreferences localSharedPreferences1;
    monitorenter;
    try
    {
      localSharedPreferences1 = paramContext.getSharedPreferences("feedback", 0);
    }
    finally
    {
      while (true)
      {
        int j;
        do
        {
          JSONArray localJSONArray1;
          int i;
          try
          {
            localJSONArray1 = new JSONArray(localSharedPreferences1.getString(str1, null));
            if ("user_reply".equals(paramJSONObject.opt("type")))
            {
              com.feedback.a.d locald = new com.feedback.a.d(localJSONArray1);
              j = localJSONArray1.length() - 1;
              break label296:
              JSONArray localJSONArray2 = new JSONArray(localSharedPreferences1.getString(str1, null));
              localJSONArray2.put(paramJSONObject);
              a(localSharedPreferences1, str1, localJSONArray2.toString());
              i = 1;
              monitorexit;
              return i;
              String str2 = localJSONArray1.getJSONObject(j).optString("reply_id", null);
              String str3 = paramJSONObject.optString("reply_id", null);
              label296: if ((str2 != null) && (str2.equalsIgnoreCase(str3)))
                a(paramContext, locald, j);
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              SharedPreferences localSharedPreferences2;
              String str4;
              String str5;
              localException.printStackTrace();
              do
              {
                while (true)
                  i = 0;
                --j;
                break label296:
                localSharedPreferences2 = paramContext.getSharedPreferences("umeng_reply_index", 0);
                str4 = localSharedPreferences2.getString(str1, "RP0");
                str5 = paramJSONObject.optString("reply_id");
              }
              while (d.a(str4, str5));
              paramJSONObject.put("datetime", t.a(new Date()));
              localJSONArray1.put(paramJSONObject);
              a(localSharedPreferences1, str1, localJSONArray1.toString());
              a(localSharedPreferences2, str1, str5);
              a(paramContext.getSharedPreferences("UmengFb_Nums", 0), "maxReplyID", str5);
              i = 1;
            }
            localObject = finally;
            monitorexit;
            throw localObject;
          }
        }
        while (j >= 0);
      }
    }
  }

  /**
   * @deprecated
   */
  public static void c(Context paramContext, String paramString)
  {
    monitorenter;
    try
    {
      paramContext.getSharedPreferences("feedback", 0).edit().remove(paramString).commit();
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  /**
   * @deprecated
   */
  public static void c(Context paramContext, JSONObject paramJSONObject)
  {
    monitorenter;
    try
    {
      b.d(paramJSONObject);
      e(paramContext, paramJSONObject);
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  /**
   * @deprecated
   */
  private static String d(Context paramContext, String paramString)
  {
    String str2;
    Object localObject2;
    monitorenter;
    try
    {
      SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("UmengFb_Nums", 0);
      String str1 = localSharedPreferences.getString("newReplyIds", "");
      boolean bool = str1.contains(paramString);
      if (bool)
      {
        localObject2 = str1;
        monitorexit;
        return localObject2;
      }
      str2 = str1 + "," + paramString;
      a(localSharedPreferences, "newReplyIds", str2);
    }
    finally
    {
      monitorexit;
    }
  }

  /**
   * @deprecated
   */
  public static void d(Context paramContext, JSONObject paramJSONObject)
  {
    monitorenter;
    try
    {
      b.c(paramJSONObject);
      e(paramContext, paramJSONObject);
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  /**
   * @deprecated
   */
  public static boolean e(Context paramContext, JSONObject paramJSONObject)
  {
    String str1;
    SharedPreferences localSharedPreferences;
    String str2;
    monitorenter;
    try
    {
      str1 = paramJSONObject.optString("feedback_id");
      str2 = localSharedPreferences.getString(str1, "[]");
    }
    finally
    {
      int i;
      try
      {
        JSONArray localJSONArray = new JSONArray(str2);
        localJSONArray.put(paramJSONObject);
        a(localSharedPreferences, str1, localJSONArray.toString());
        i = 1;
        monitorexit;
        return i;
      }
      catch (JSONException localJSONException)
      {
        while (true)
        {
          localJSONException.printStackTrace();
          i = 0;
        }
        localObject = finally;
        monitorexit;
        throw localObject;
      }
    }
  }
}